<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="common :: header('WeiAdmin')"/>
    <link href="/admin/css/loader.css" rel="stylesheet"/>
    <link href="/admin/css/admin.css" rel="stylesheet"/>
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="settingForm" action="" onsubmit="return false">
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li class="layui-this">存储设置</li>
                </ul>

                <div class="layui-tab-content" >
                    <div class="layui-form-item">
                        <label class="layui-form-label" id="tabHeader">存储方式</label>
                        <div>
                            <input checked name="storate_type" lay-filter="type-radio-filter" class="layui-radio layui-this" title="本地"
                                   type="radio" value="1" th:checked="${info.storate_type eq '1'}">
                            <input name="storate_type" lay-filter="type-radio-filter" class="layui-radio" title="阿里云存储" type="radio"
                                   value="2" th:checked="${info.storate_type eq '2'}">
                            <input name="storate_type" lay-filter="type-radio-filter" class="layui-radio"  title="腾讯云存储" type="radio"
                                   value="3" th:checked="${info.storate_type eq '3'}">
                        </div>
                    </div>
                    <div id="tabBody">
                        <div id="tab1" th:class="${info.storate_type=='1'} ? 'layui-tab-item layui-show':'layui-tab-item' ">

                            <div class="layui-form-item">
                                <label class="layui-form-label">存储路径</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="file_path"
                                           placeholder="请输入存储路径" autocomplete="off" class="layui-input"
                                           th:value="${info.file_path}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">图片大小限制(M)</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="file_image_size"
                                           placeholder="请输入文件大小限制" autocomplete="off" class="layui-input"
                                           th:value="${info.file_image_size}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">文件大小限制(M)</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="file_size"
                                           placeholder="请输入文件大小限制" autocomplete="off" class="layui-input"
                                           th:value="${info.file_size}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="pear-btn pear-btn-primary" lay-submit lay-filter="formDemo">保存</button>
                                </div>
                            </div>
                        </div>
                        <div id="tab2" th:class="${info.storate_type=='2'} ? 'layui-tab-item layui-show':'layui-tab-item' ">
                            <div class="layui-form-item">
                                <label class="layui-form-label">AccessKey</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="ali_accessKey"
                                           placeholder="请输入AccessKey" autocomplete="off" class="layui-input"
                                           th:value="${info.ali_accessKey}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">SecretKey</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="ali_secretKey"
                                           placeholder="请输入SecretKey" autocomplete="off" class="layui-input"
                                           th:value="${info.ali_secretKey}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">访问域名（Bucket 域名）</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="ali_domain"
                                           placeholder="请输入应用名称" autocomplete="off" class="layui-input"
                                           th:value="${info.ali_domain}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">空间名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="ali_bucket"
                                           placeholder="请输入存储桶" autocomplete="off" class="layui-input"
                                           th:value="${info.ali_bucket}"
                                    >
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">要上传的文件夹</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="ali_filepath"
                                           placeholder="请输入要上传的文件夹" autocomplete="off" class="layui-input"
                                           th:value="${info.ali_filepath}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="pear-btn pear-btn-primary" lay-submit lay-filter="formDemo">保存</button>
                                </div>
                            </div>
                        </div>
                        <div id="tab3" class="layui-tab-item" th:class="${info.storate_type=='3'} ? 'layui-tab-item layui-show':'layui-tab-item' ">

                            <div class="layui-form-item">
                                <label class="layui-form-label">AccessID</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="tecent_accessID"
                                           placeholder="请输入AccessID" autocomplete="off" class="layui-input"
                                           th:value="${info.tecent_accessID}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">AccessKey</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="tecent_accessKey"
                                           placeholder="请输入AccessKey" autocomplete="off" class="layui-input"
                                           th:value="${info.tecent_accessKey}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">访问域名（存储桶 域名）</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="tecent_domain"
                                           placeholder="请输入访问域名（存储桶 域名）" autocomplete="off" class="layui-input"
                                           th:value="${info.tecent_domain}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">存储桶</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="tecent_bucket"
                                           placeholder="请输入存储桶" autocomplete="off" class="layui-input"
                                           th:value="${info.tecent_bucket}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">要上传的文件夹</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="tecent_filepath"
                                           placeholder="请输入要上传的文件夹" autocomplete="off" class="layui-input"
                                           th:value="${info.tecent_filepath}"
                                    >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="pear-btn pear-btn-primary" lay-submit lay-filter="formDemo">保存</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
</div>
<th:block th:include="common :: footer"/>
<script>
    layui.use(['element','form','laydate','jquery','upload'], function(){
      var form = layui.form;
      let $ = layui.jquery;

      form.on('radio(type-radio-filter)', function(data){
          let value = data.elem.value;
          let tabid = "#tab" +  value;
          $(".layui-tab-item").hide();
          $(".layui-tab-item").removeClass("layui-show");
          $(tabid).show();
      })
      form.on('submit(formDemo)', function(data){
          debugger;
          $.ajax({
                url: '/admin/plugin/updateOss',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            //parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            //parent.layui.table.reload("role-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
          return false;
      });
    });

</script>
</body>
</html>